Crate mahf

source ·
Expand description

A framework for the modular construction and evaluation of metaheuristics.

MAHF allows easy construction and experimental analysis of metaheuristics by decomposing them into their fundamental components.

The framework supports not only evolutionary algorithms, but also any other metaheuristic frameworks, including non-population-based, constructive, and especially hybrid approaches.

Overview

MAHF aims to make the construction and modification of metaheuristics as simple and reliable as possible. It provides a comprehensive set of utilities for logging, evaluation, and comparison of these heuristics.

Key features include:

  • Simple and modular metaheuristic construction
  • Effortless state management and tracking
  • Ready-to-use collection of common operators
  • Templates for popular metaheuristics
  • Flexible logging of runtime information

Although MAHF has been developed primarily as a research tool, it can be used to solve real-world problems.

Example

Defining a simple genetic algorithm for real-valued black-box optimization:

use mahf::prelude::*;

let ga = Configuration::builder()
    .do_(initialization::RandomSpread::new(population_size))
    .evaluate()
    .update_best_individual()
    .while_(conditions::LessThanN::iterations(n), |builder| {
       builder
           .do_(selection::Tournament::new(num_selected, size))
           .do_(recombination::ArithmeticCrossover::new_insert_both(pc))
           .do_(mutation::NormalMutation::new(std_dev, rm))
           .do_(boundary::Saturation::new())
           .evaluate()
           .update_best_individual()
           .do_(replacement::MuPlusLambda::new(max_population_size))
    })
    .build();

Component-based design

MAHF is based on the concept of unified metaheuristics, which means that we interpret metaheuristics to be composed of components and conditions that can be mixed and matched. They are represented by the Component and Condition traits.

Putting components together into a metaheuristic is as easy as writing pseudo-code thanks to the Configuration::builder, as you can see in the example.

Runtime state

Components can only realize complex functionality if they can communicate freely, and the State offers a way to do it. The State is a shared blackboard where components can insert, read, write, and remove so-called CustomState.

Optimization problems

Optimization problems are represented by the Problem and Evaluate traits:

  • Problem and subtraits offer a way to provide any problem-specific information to components and allow them to be as generic as possible by only specifying the minimal trait bounds they need to function
  • Evaluate provides means of evaluating the objective function, e.g. in parallel

Optimizing some problem is then as easy as calling Configuration::optimize.

Metaheuristic templates

MAHF offers pre-built modular templates for a dozen of common metaheuristics as a starting point for more complex hybrids. Take a look at their implementation if you want to get a feel for how different metaheuristics are represented in MAHF.

Citing MAHF

If you use MAHF in a scientific publication, we would appreciate citations to the following paper:

Helena Stegherr, Leopold Luley, Jonathan Wurth, Michael Heider, and Jörg Hähner. 2023. A framework for modular construction and evaluation of metaheuristics. Fakultät für Angewandte Informatik. https://opus.bibliothek.uni-augsburg.de/opus4/103452

Bibtex entry:

@techreport{stegherr2023,
  author    = {Helena Stegherr and Leopold Luley and Jonathan Wurth and Michael Heider and J{\"o}rg H{\"a}hner},
  title     = {A framework for modular construction and evaluation of metaheuristics},
  institution = {Fakult{\"a}t f{\"u}r Angewandte Informatik},
  series    = {Reports / Technische Berichte der Fakult{\"a}t f{\"u}r Angewandte Informatik der Universit{\"a}t Augsburg},
  number    = {2023-01},
  pages     = {25},
  year      = {2023},
}

Modules

  • Base utilities for components, conditions, and lenses.
  • Metaheuristic algorithm components.
  • Metaheuristic algorithm conditions.
  • Metaheuristic configurations.
  • Utilities for performing experiments.
  • (Meta)Heuristic templates.
  • Identifiers to distinguish between different components of the same type.
  • Access arbitrary state without knowing the exact type of the container.
  • Utilities for logging.
  • Helper traits for dealing with collections of individuals, i.e. populations, and obtaining &, &mut or owned solutions from them.
  • The MAHF prelude imports the most relevant modules, structs and traits you may need for experiments.
  • Optimization problems.
  • Runtime state of a (meta)heuristic.
  • A collection of utilities.